@extends('admin.app')

@section('content')
  <div class="panel panel-default">
    <div class="panel-heading font-bold">
      发放活动红包
    </div>
    <div class="panel-body">
      <form class="form-horizontal form-validation" action="{{ admin_action('Gift\RecordController@store',[$activity]) }}" method="post">
        {{ csrf_field() }}
        <div class="form-group">
          <label class="col-lg-2 control-label">发放事由*</label>
          <div class="col-lg-10">
            <input type="text" class="form-control" name="reason" value="{{ old('reason') }}" placeholder="请输入名称" data-rule-required="true" data-rule-maxlength="200"/> 
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">发放的用户类型*</label>
          <div class="col-lg-10">
            <select name="grant_type" class="form-control select2" id="opt1">
              <option value="1">指定用户</option>
              <option value="0">全部用户</option>
            </select>
          </div>
        </div>
        <div class="form-group">
          <label class="col-lg-2 control-label">选择用户</label>
          <div class="col-lg-10">
            <select name="user_id[]" class="form-control select2" multiple>
              @foreach($users as $item)
              <option value="{{$item->id}}">{{$item->username}}</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">发放金额*</label>
          <div class="col-lg-10">
            <input type="text" class="form-control" name="money" value="{{ old('money') }}" placeholder="请输入名称" data-rule-required="true"/> 
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <div class="col-lg-4 col-lg-offset-2">
            <a href="{{ admin_action('Gift\RecordController@index',[$activity]) }}" class="btn btn-default">返&nbsp;回</a>
            <button type="submit" class="btn btn-primary">保&nbsp;存</button>
          </div>
        </div>
      </form>
    </div>
  </div>
@endsection
@section('scripts')
<script type="text/javascript">
$(function(){
  $("#opt1").change(function(){
    if($(this).val()==1){
      $("select[multiple]").parents(".form-group").removeClass('hide');
    }else{
      $("select[multiple]").parents(".form-group").addClass('hide');
    }
  });
})
</script>
@endsection